package com.tomek.def;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import sun.org.mozilla.javascript.json.JsonParser;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

@WebServlet("/JsonData")
public class JsonData extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public JsonData() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		JSONArray jsonArray = new JSONArray();
		
		JSONObject jObject = new JSONObject();
		jObject.accumulate(Drinks.HERBATA.getType(), Drinks.HERBATA.getId());
		jObject.accumulate(Drinks.KAWA.getType(), Drinks.KAWA.getId());
		jObject.accumulate(Drinks.WODA_MINERALNA.getType(), Drinks.WODA_MINERALNA.getId());
		
		jsonArray.add(jObject);
		
		PrintWriter writer = response.getWriter();
		writer.write(jsonArray.toString());
	}

}
